<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>象过河云进销存</title>
		<style type="text/css">
			body{
				font-size: 1.5rem;
				width: 100%;
			}
		</style>
	</head>
	<script src="js/v3.2.8/vue.global.prod.js" type="text/javascript" charset="utf-8"></script>
	<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
	<link rel="stylesheet" href="css/index.css" />
	<body>
		<div id="app" style="width: 100%;">
			<div style="width: 100%;font-weight: 300;"  :style="isMobile ? '' : 'display:flex;justify-content: center;'" >
			<div style="padding: 50px 70px;" :style="isMobile ? '' : 'max-width:500px;'">
				<div class="companyName">
					{{ companyData.companyName }}
				</div>
				<div class="billName">
					{{ billData.orderType_dictText }}
				</div>
				<div class="line-hidden">
					******************************************************************************************************************************
				</div>
				<div>
					<div class="line-text" v-for="(item, index) in header" :key="index">{{item}}</div>
				</div>
				<div class="line-hidden">
					******************************************************************************************************************************
				</div>
				<div v-if="['skjsd', 'fkjsd', 'wldsjsd', 'wldfjsd', 'wlyfjsd'].includes(billType)">
					<div style="display: flex;font-weight: 400;">
						<div style="width: 50%;">账户名称</div>
						<div style="width: 50%;">金额</div>
					</div>
					<template v-for="(item, index) in accountList" :key="index">
						<div style="display: flex;">
							<div style="width: 50%;">{{item.bankName}}</div>
							<div style="width: 50%;">{{item.price}}</div>
						</div>
					</template>
					<div class="line-hidden">
						******************************************************************************************************************************
					</div>
					<template v-for="(item, index) in billList" :key="index">
						<div v-if="['skjsd', 'wldsjsd'].includes(billType)">
							<div>应收款类型：{{ item.type }}</div>
							<div>应收款单号：{{ item.settlementOrderNumber }}</div>
							<div>应收金额：{{ item.surplusPrice }}</div>
						</div>
						<div v-else>
							<div>应付款类型：{{ item.type }}</div>
							<div>应付款单号：{{ item.settlementOrderNumber }}</div>
							<div>应付金额：{{ item.surplusPrice }}</div>
						</div>
						<div>当前已结销：{{ item.thisPrice }}</div>
						<div class="line-dashed" v-if="index < billList.length - 1"></div>
					</template>
					<div class="line-hidden" v-if="billList.length > 0">
						******************************************************************************************************************************
					</div>
				</div>
				<div v-else-if="billType == 'zzd'">
					<div style="display: flex;font-weight: 400;">
						<div style="width: 50%;">转入账户名称</div>
						<div style="width: 50%;">金额</div>
					</div>
					<template v-for="(item, index) in accountList" :key="index">
						<div style="display: flex;">
							<div style="width: 50%;">{{item.inBankId_dictText}}</div>
							<div style="width: 50%;">{{item.inPrice}}</div>
						</div>
					</template>
					<div class="line-hidden">
						******************************************************************************************************************************
					</div>
				</div>
				<div v-else-if="['ybfyd', 'qtsrd'].includes(billType)">
					<div style="display: flex;font-weight: 400;">
						<div style="width: 50%;" v-if="billType == 'ybfyd'">费用名称</div>
						<div style="width: 50%;" v-else>收入名称</div>
						<div style="width: 50%;">金额</div>
					</div>
					<template v-for="(item, index) in accountList" :key="index">
						<div style="display: flex;">
							<div style="width: 50%;">{{item.costName}}</div>
							<div style="width: 50%;">{{item.price}}</div>
						</div>
					</template>
					<div class="line-hidden">
						******************************************************************************************************************************
					</div>
				</div>
				<div v-else-if="billType == 'cghhd' || billType == 'xshhd'">
					<div class="table-head" >
						<span>商品</span>
						<span>单价</span>
						<span>数量</span>
						<span>金额</span>
					</div>
					<div style="color: black;font-weight: 400;margin: 5px 0;">换出明细：</div>
					<template v-for="(item, index) in goodsList1" :key="index">
						<div>{{ item.goodsName }}</div>
						<div class="table-head">
							<span></span>
							<span>{{item.price}}</span>
							<span>{{item.number}}</span>
							<span>{{item.allPrice}}</span>
						</div>
						<div class="line-dashed" v-if="index < goodsList.length - 1"></div>
					</template>
					<div class="line-hidden">
						******************************************************************************************************************************
					</div>
					<div class="table-head">
						<span style="text-align: left;">合计</span>
						<span></span>
						<span>{{billData.outNum || 0}}</span>
						<span>{{billData.outAll || 0}}</span>
					</div>
					<div style="color: black;font-weight: 400;margin: 5px 0;">换入明细：</div>
					<template v-for="(item, index) in goodsList" :key="index">
						<div>{{ item.goodsName }}</div>
						<div class="table-head">
							<span></span>
							<span>{{item.price}}</span>
							<span>{{item.number}}</span>
							<span>{{item.allPrice}}</span>
						</div>
						<div class="line-dashed" v-if="index < goodsList.length - 1"></div>
					</template>
					<div class="line-hidden">
						******************************************************************************************************************************
					</div>
					<div class="table-head">
						<span class="table-item" style="text-align: left;">合计</span>
						<span class="table-item"></span>
						<span class="table-item">{{billData.inNum || 0}}</span>
						<span class="table-item">{{billData.inAll || 0}}</span>
					</div>
				 </div>
				<div v-else>
					<div class="table-head" >
						<span>商品</span>
						<span>单价</span>
						<span>数量</span>
						<span>金额</span>
					</div>
					<template v-for="(item, index) in goodsList" :key="index">
						<div>{{ item.goodsName }}</div>
						<div class="table-head">
							<span class="table-item"></span>
							<span class="table-item">{{item.price}}</span>
							<span class="table-item">{{item.number}}</span>
							<span class="table-item">{{item.allPrice}}</span>
						</div>
						<div class="line-dashed" v-if="index < goodsList.length - 1"></div>
					</template>
					<div class="line-hidden">
						******************************************************************************************************************************
					</div>
					<div class="table-head">
						<span class="table-item" style="text-align: left;">合计</span>
						<span class="table-item"></span>
						<span class="table-item">{{billData.allNumber || 0}}</span>
						<span class="table-item">{{billData.allPrice || 0}}</span>
					</div>
				</div>
				<div>
					<div class="line-text" v-for="(item, index) in footer" :key="index">{{item}}</div>
				</div>
			</div>
		</div>
		</div>
		<script>

		</script>
		<script>
			const App = {
				data() {
					return {
						companyData: {},
						billData: {},
						billType: '',
						header: [],
						footer: [],
						goodsList: [],
						goodsList1: [],
						isMobile: false,
						accountList: [], //收付款账户列表
						billList: [], //收付款单据列表
						
						// api: 'http://192.168.2.65:10030/api',
						api: 'https://yun.xiangguohe.cn/api',

						bookUrl: '/accountbookinfo/xghAccountBook/queryById',
						paths: {
							'cgdd': '/xghPurchaseOrder/xghPurchaseOrder/getPurchaseOrderById',
							'cgrkd': '/xghBuyOrder/xghBuyOrder/getBuyOrderById',
							'cgthd': '/xghBuyOrder/xghBuyOrder/getBuyOrderById',
							'cghhd': '/xghBuyOrder/xghBuyOrder/getBuyOrderById',
							'xsdd': '/xghSaleOrder/xghSaleOrder/getOrderById',
							'xsckd': '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/getBuyOrderById',
							'xsthd': '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/getBuyOrderById',
							'xshhd': '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/getBuyOrderById',
							'pdd': '/xghCheckOrder/xghCheckOrder/queryById',
							'dbd': '/xghAllotOrder/xghAllotOrder/getById',
							'bsd': '/xghProfitLossOrder/xghProfitLossOrder/getById',
							'byd': '/xghProfitLossOrder/xghProfitLossOrder/getById',
							'cbtzd': '/xghAdjustOrder/xghAdjustOrder/queryById',
							'qtrkd': '/xghBuyOrder/xghBuyOrder/getBuyOrderById',
							'qtckd': '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/getBuyOrderById',
							'skjsd': '/xghSettlementOrder/xghSettlementOrder/getById',
							'fkjsd': '/xghSettlementOrder/xghSettlementOrder/getById',
							'wldsjsd': '/xghSettlementOrder/xghSettlementOrder/getById',
							'wldfjsd': '/xghSettlementOrder/xghSettlementOrder/getById',
							'wlyfjsd': '/xghSettlementOrder/xghSettlementOrder/getById',
							'zzd': '/transfer/xghTransferOrder/queryById',
							'ybfyd': '/costOrder/xghGeneralCostOrder/queryById',
							'qtsrd': '/costOrder/xghGeneralCostOrder/queryById'
						}, //单据详情接口
					}
				},
				created() {
					let that = this
					var userAgent = navigator.userAgent || navigator.vendor || window.opera
 
					// 使用正则表达式来检查userAgent字符串中是否包含某些关键字
					// 这些关键字通常与移动设备相关
					var mobile = /windows phone|iphone|ipad|ipod|android|blackberry|mini|windows ce|palm/i.test(
						userAgent.toLowerCase()
					)
					that.isMobile = mobile
					if (mobile) {
						// 如果userAgent包含上述关键字之一，则认为是在移动设备上
						console.log('访问设备是移动设备')
					} else {
						// 否则，认为是在PC（桌面设备）上
						console.log('访问设备是PC（桌面设备）')
					}
					console.log(that.isMobile);
					
					
					let url = window.location.search
					const regex = /[?&]+([^=&]+)=([^&]*)/gi;
					const params = {};
					url.replace(regex, function(_, key, value) {
						params[key] = decodeURIComponent(value);
					});
					console.log(params);
					that.billType = params.from
					
					if (params.aid) {
						$.ajax({
							type: "get", // 请求方式
							url: this.api + this.bookUrl, // 请求路径
							dataType: "json", // 预期返回一个 json 类型数据
							data: {
								id: params.aid
							},
							success: function(res) {
								console.log(res);
								that.companyData = res.result || {}
							},
							error: function(xhr) {
								// 只有请求不正常才会执行（状态码不为200）
								console.log(xhr)
							},
						});
					}

					if (this.paths.hasOwnProperty(params.from)) {
						$.ajax({
							type: "get", // 请求方式
							url: this.api + this.paths[params.from], // 请求路径
							dataType: "json", // 预期返回一个 json 类型数据
							data: {
								xghAccountBookId: params.aid,
								accountBookId: params.aid,
								abId: params.aid,
								id: params.bid
							},
							// headers: {
							// 	'X-Access-Token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3Mjg3MjI3NTAsInVzZXJuYW1lIjoiMTg1MzkyOTI1MTcifQ.RABUnhqzXqNyJ-m9vWUwKAgLZtFHMY_z3mk7iodMM7A'
							// },
							success: function(res) {
								console.log(res);
								if (!res.success) {
									alert('获取单据信息失败！')
									return
								}
								let result = res.result || {}
								
								console.log(that.billType);
								let goodsResult = []
								if (that.billType == 'xsdd') {
									//销售订单
									let data = result.saleOrderPage
									data.orderType_dictText = '销售订单'
									goodsResult = data.xghSaleOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.billData.allPrice = data.orderAllPrice
									that.header = [
										`客户名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.orderTime}`,
										`出货仓库：${data.xghStorehouseId_dictText}`,
									]
									that.footer = [
										`整单优惠：￥${data.orderDiscountPrice || 0}`,
										`预收定金：￥${data.depositPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								 else if (that.billType == 'xsckd') {
									//销售出库单
									let data = result.saleStorehouseOrderPage
									goodsResult = data.xghSaleStorehouseOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.header = [
										`客户名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.outTime}`,
										`出货仓库：${data.xghOutStorehouseId_dictText}`,
									]
									that.footer = [
										`整单优惠：￥${data.orderDiscountPrice || 0}`,
										`本次收款：￥${data.collectionPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								 else if (that.billType == 'xsthd') {
									//销售退货单
									let data = result.saleStorehouseOrderPage
									goodsResult = data.xghSaleStorehouseOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.header = [
										`客户名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.outTime}`,
										`退货仓库：${data.xghOutStorehouseId_dictText}`,
									]
									that.footer = [
										`整单优惠：￥${data.orderDiscountPrice || 0}`,
										`本次退款：￥${data.collectionPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								 else if (that.billType == 'xshhd') {
									//销售换货单
									let data = result.saleStorehouseOrderPage
									goodsResult = data.xghSaleStorehouseOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.header = [
										`客户名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.outTime}`,
										`换入仓库：${data.xghStorehouseId_dictText}`,
										`换出仓库：${data.xghOutStorehouseId_dictText}`,
									]
									that.footer = [
										`换货差额：￥${data.receivablePrice || 0}`,
										`整单优惠：￥${data.orderDiscountPrice || 0}`,
										`本次退款：￥${data.collectionPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								 else if (that.billType == 'cgdd') {
									//采购订单
									let data = result.purchaseOrderPage
									data.allPrice = data.purchaseOrderPrice + data.rebatePrice
									data.orderType_dictText = '采购订单'
									goodsResult = data.xghPurchaseOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.header = [
										`供应商名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.orderTime}`,
										`入货仓库：${data.xghStorehouseId_dictText}`,
									]
									that.footer = [
										`整单优惠：￥${data.rebatePrice || 0}`,
										`预付定金：￥${data.depositPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								 else if (that.billType == 'cgrkd') {
									//采购入库单
									let data = result.buyOrderPage
									data.orderType_dictText = data.buyType_dictText
									goodsResult = data.xghBuyOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.header = [
										`供应商名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.putTime}`,
										`入货仓库：${data.xghStorehouseId_dictText}`,
									]
									that.footer = [
										`整单优惠：￥${data.rebatePrice || 0}`,
										`本次付款：￥${data.payPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								 else if (that.billType == 'cgthd') {
									//采购退货单
									let data = result.buyOrderPage
									data.orderType_dictText = data.buyType_dictText
									goodsResult = data.xghBuyOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.header = [
										`供应商名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.putTime}`,
										`退货仓库：${data.xghStorehouseId_dictText}`,
									]
									that.footer = [
										`整单优惠：￥${data.rebatePrice || 0}`,
										`本次退款：￥${data.payPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								 else if (that.billType == 'cghhd') {
									//采购换货单
									let data = result.buyOrderPage
									data.orderType_dictText = data.buyType_dictText
									goodsResult = data.xghBuyOrderInfoList
									let list = result.collectionPayPage.xghCollectionPayInfoList
									let names = list.map(item => {return item.bankName})
									that.billData = data
									that.header = [
										`供应商名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.putTime}`,
										`换出仓库：${data.xghOutStorehouseId_dictText}`,
										`换入仓库：${data.xghStorehouseId_dictText}`,
									]
									that.footer = [
										`换货差额：￥${data.receivablePrice || 0}`,
										`整单优惠：￥${data.rebatePrice || 0}`,
										`本次付款：￥${data.payPrice || 0}`,
										`结算账户：${names.join(';')}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'pdd') {
									//盘点单
									let data = result
									data.orderType_dictText = '盘点单'
									goodsResult = data.orderInfoList
									that.billData = data
									that.header = [
										`单据编号：${data.serialNumber}`,
										`盘点时间：${data.checkTime}`,
										`盘点仓库：${data.xghStorehouseIdText || ''}`,
										`经手人：${data.sysUserIdText || ''}`,
									]
									that.footer = [
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'dbd') {
									//调拨单
									let data = result
									data.orderType_dictText = '调拨单'
									goodsResult = data.allotOrderInfoList
									that.billData = data
									that.header = [
										`单据编号：${data.orderNumber}`,
										`调拨时间：${data.commitTime}`,
										`调出仓库：${data.xghCStorehouseIdText || ''}`,
										`调入仓库：${data.xghRStorehouseIdText || ''}`,
										`经手人：${data.sysUserIdText || ''}`,
									]
									that.footer = [
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'bsd') {
									//报损单
									let data = result
									data.orderType_dictText = '报损单'
									goodsResult = data.infoList
									that.billData = data
									that.header = [
										`单据编号：${data.orderNumber}`,
										`报损时间：${data.commitTime}`,
										`报损仓库：${data.xghStorehouseIdText || ''}`,
										`经手人：${data.sysUserIdText || ''}`,
									]
									that.footer = [
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'byd') {
									//报溢单
									let data = result
									data.orderType_dictText = '报溢单'
									goodsResult = data.infoList
									that.billData = data
									that.header = [
										`单据编号：${data.orderNumber}`,
										`报溢时间：${data.commitTime}`,
										`报溢仓库：${data.xghStorehouseIdText || ''}`,
										`经手人：${data.sysUserIdText || ''}`,
									]
									that.footer = [
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'cbtzd') {
									//成本调整单
									let data = result
									data.orderType_dictText = '成本调整单'
									goodsResult = data.infoList
									that.billData = data
									that.header = [
										`单据编号：${data.orderNumber}`,
										`调整时间：${data.commitTime}`,
										`调整仓库：${data.xghStorehouseIdText || ''}`,
										`经手人：${data.sysUserIdText || ''}`,
									]
									that.footer = [
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'qtrkd') {
									//其他入库单
									let data = result.buyOrderPage
									data.orderType_dictText = data.buyType_dictText
									goodsResult = data.xghBuyOrderInfoList
									that.billData = data
									that.header = [
										`供应商名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.putTime}`,
										`入货仓库：${data.xghStorehouseId_dictText}`,
									]
									that.footer = [
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'qtckd') {
									//其他出库单
									let data = result.saleStorehouseOrderPage
									goodsResult = data.xghSaleStorehouseOrderInfoList
									that.billData = data
									that.header = [
										`客户名称：${data.xghCompanyId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
										`单据编号：${data.orderNumber}`,
										`业务日期：${data.outTime}`,
										`出货仓库：${data.xghOutStorehouseId_dictText}`,
									]
									that.footer = [
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'skjsd') {
									//收款结算单
									let data = result.xghSettlementOrderPage
									that.accountList = result.collectionPayPage.xghCollectionPayInfoList
									that.billList = data.xghSettlementOrderInfoList
									that.billData = data
									that.header = [
										`收款日期：${data.collectionTime}`,
										`单据编号：${data.orderNumber}`,
										`往来单位：${data.xghCompanyId_dictText || ''}`,
										`收款类型：${data.settlementTypeId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
									]
									that.footer = [
										`整单优惠：￥${data.discountPrice || 0}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'fkjsd') {
									//付款结算单
									let data = result.xghSettlementOrderPage
									that.accountList = result.collectionPayPage.xghCollectionPayInfoList
									that.billList = data.xghSettlementOrderInfoList
									that.billData = data
									that.header = [
										`付款日期：${data.collectionTime}`,
										`单据编号：${data.orderNumber}`,
										`供应商：${data.xghCompanyId_dictText || ''}`,
										`付款类型：${data.settlementTypeId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
									]
									that.footer = [
										`整单优惠：￥${data.discountPrice || 0}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'wldsjsd') {
									//物流代收结算单
									let data = result.xghSettlementOrderPage
									that.accountList = result.collectionPayPage.xghCollectionPayInfoList
									that.billList = data.xghSettlementOrderInfoList
									that.billData = data
									that.header = [
										`收款日期：${data.collectionTime}`,
										`单据编号：${data.orderNumber}`,
										`物流公司：${data.xghExpressId_dictText || ''}`,
										`经手人：${data.sysUserId_dictText || ''}`,
									]
									that.footer = [
										`整单优惠：￥${data.discountPrice || 0}`,
										`手续费：￥${data.serviceCharge || 0}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'wldfjsd') {
									//物流代付结算单
									let data = result.xghSettlementOrderPage
									that.accountList = result.collectionPayPage.xghCollectionPayInfoList
									that.billList = data.xghSettlementOrderInfoList
									that.billData = data
									that.header = [
										`付款日期：${data.collectionTime}`,
										`单据编号：${data.orderNumber}`,
										`物流公司：${data.xghExpressId_dictText || ''}`,
										`经手人：${data.sysUserId_dictText || ''}`,
									]
									that.footer = [
										`整单优惠：￥${data.discountPrice || 0}`,
										`手续费：￥${data.serviceCharge || 0}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'wlyfjsd') {
									//物流运费结算单
									let data = result.xghSettlementOrderPage
									that.accountList = result.collectionPayPage.xghCollectionPayInfoList
									that.billList = data.xghSettlementOrderInfoList
									that.billData = data
									that.header = [
										`付款日期：${data.collectionTime}`,
										`单据编号：${data.orderNumber}`,
										`物流公司：${data.xghExpressId_dictText || ''}`,
										`付款类型：${data.settlementTypeId_dictText}`,
										`经手人：${data.sysUserId_dictText || ''}`,
									]
									that.footer = [
										`整单优惠：￥${data.discountPrice || 0}`,
										`手续费：￥${data.serviceCharge || 0}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'zzd') {
									//转账单
									let data = result.xghTransferOrder
									that.accountList = data.xghTransferOrderInfoList
									data.orderType_dictText = '转账单'
									that.billData = data
									that.header = [
										`转账日期：${data.createOrderDate}`,
										`单据编号：${data.orderNumber}`,
										`转出账户：${data.outBankId_dictText || ''}`,
										`转出金额：${data.outPrice || 0}`,
										`经手人：${data.sysUserIdText || ''}`,
									]
									that.footer = [
										`手续费：￥${data.commissionPrice || 0}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'ybfyd') {
									//一般费用单
									let data = result.costOrderPage
									that.accountList = data.xghGeneralCostOrderInfoList
									data.orderType_dictText = '一般费用单'
									that.billData = data
									that.header = [
										`付款日期：${data.createOrderDate}`,
										`单据编号：${data.orderNumber}`,
										`付款账户：${data.bankId_dictText || ''}`,
										`付出金额：${data.payPrice || 0}`,
										`往来单位：${data.xghCompanyId_dictText || ''}`,
										`经手人：${data.sysUserId_dictText || ''}`,
									]
									that.footer = [
										`优惠金额：￥${data.rebatePrice || 0}`,
										`备注：${data.remark}`,
									]
								}
								else if (that.billType == 'qtsrd') {
									//其他收入单
									let data = result.costOrderPage
									that.accountList = data.xghGeneralCostOrderInfoList
									data.orderType_dictText = '其他收入单'
									that.billData = data
									that.header = [
										`收款日期：${data.createOrderDate}`,
										`单据编号：${data.orderNumber}`,
										`收款账户：${data.bankId_dictText || ''}`,
										`收入金额：${data.payPrice || 0}`,
										`往来单位：${data.xghCompanyId_dictText || ''}`,
										`经手人：${data.sysUserId_dictText || ''}`,
									]
									that.footer = [
										`优惠金额：￥${data.rebatePrice || 0}`,
										`备注：${data.remark}`,
									]
								}
								
								//商品信息
								if (that.billType == 'xshhd') {
									let inList = []
									let outList = []
									for (let index = 0; index < goodsResult.length; index++) {
										const item = goodsResult[index];
										let name = `${item.goodsName} ${item.norms || ''} ${item.barCode || ''} ${item.goodsNumber || ''}`
										let nItem = {
											goodsName: name,
											price: item.salePrice,
											number: `${item.number}/${item.unit}`,
											allPrice: item.allPrice,
											num: item.number
										}
										if (item.saleOrderType == 1) {
											inList.push(nItem)
        								} else {
											outList.push(nItem)
										}
									}
									that.goodsList = inList
									that.goodsList1 = outList
									const sum = inList.reduce((acc, obj) => acc + obj.allPrice, 0);
									const sum1 = outList.reduce((acc, obj) => acc + obj.allPrice, 0);
									const sum2 = inList.reduce((acc, obj) => acc + obj.num, 0);
									const sum3 = outList.reduce((acc, obj) => acc + obj.num, 0);
									console.log(sum2);
									
									that.billData.outAll = sum1
									that.billData.inAll = sum
									that.billData.outNum = sum3
									that.billData.inNum = sum2
								}
								 else if (that.billType == 'cghhd') {
									let inList = []
									let outList = []
									for (let index = 0; index < goodsResult.length; index++) {
										const item = goodsResult[index];
										let name = `${item.goodsName} ${item.norms || ''} ${item.barCode || ''} ${item.goodsNumber || ''}`
										let nItem = {
											goodsName: name,
											price: item.salePrice,
											number: `${item.number}/${item.unit}`,
											allPrice: item.allPrice,
											num: item.number
										}
										if (item.status == 1) {
											inList.push(nItem)
        								} else {
											outList.push(nItem)
										}
									}
									that.goodsList = inList
									that.goodsList1 = outList
									const sum = inList.reduce((acc, obj) => acc + obj.allPrice, 0);
									const sum1 = outList.reduce((acc, obj) => acc + obj.allPrice, 0);
									const sum2 = inList.reduce((acc, obj) => acc + obj.num, 0);
									const sum3 = outList.reduce((acc, obj) => acc + obj.num, 0);
									that.billData.outAll = sum1
									that.billData.inAll = sum
									that.billData.outNum = sum3
									that.billData.inNum = sum2
								}
								 else if (['xsdd', 'xsckd', 'xsthd', 'cgdd', 'cgrkd', 'cgthd', 'qtrkd', 'qtckd'].includes(that.billType)) {
									that.goodsList = goodsResult.map(item => {
										let name = `${item.goodsName} ${item.norms || ''} ${item.barCode || ''} ${item.goodsNumber || ''}`
										return {
											goodsName: name,
											price: item.salePrice || item.discountUnitPrice,
											number: `${item.number}/${item.unit}`,
											allPrice: item.allPrice
										}
									})
									const sum = goodsResult.reduce((acc, obj) => acc + obj.number, 0);
									that.billData.allNumber = sum
								}
								 else if (['pdd', 'bsd', 'byd'].includes(that.billType)) {
									that.goodsList = goodsResult.map(item => {
										let name = `${item.goodsName} ${item.norms || ''} ${item.barCode || ''} ${item.goodsNumber || ''}`
										return {
											goodsName: name,
											price: item.costPrice,
											number: `${item.number}/${item.unit}`,
											allPrice: item.price
										}
									})
									const sum = goodsResult.reduce((acc, obj) => acc + obj.number, 0);
									that.billData.allNumber = sum
									const sum1 = goodsResult.reduce((acc, obj) => acc + obj.price, 0);
									that.billData.allPrice = sum1
								}
								else if (that.billType == 'dbd') {
									that.goodsList = goodsResult.map(item => {
										let name = `${item.goodsName} ${item.norms || ''} ${item.barCode || ''} ${item.goodsNumber || ''}`
										return {
											goodsName: name,
											price: item.allotPrice,
											number: `${item.number}/${item.unit}`,
											allPrice: item.allotAllprice
										}
									})
									const sum = goodsResult.reduce((acc, obj) => acc + obj.number, 0);
									that.billData.allNumber = sum
									const sum1 = goodsResult.reduce((acc, obj) => acc + obj.allotAllprice, 0);
									that.billData.allPrice = sum1
								}
								else if (that.billType == 'cbtzd') {
									that.goodsList = goodsResult.map(item => {
										let name = `${item.goodsName} ${item.norms || ''} ${item.barCode || ''} ${item.goodsNumber || ''}`
										return {
											goodsName: name,
											price: item.newPrice,
											number: `${item.updateNumber}/${item.unit}`,
											allPrice: item.newPrice * item.updateNumber
										}
									})
									const sum = goodsResult.reduce((acc, obj) => acc + obj.updateNumber, 0);
									that.billData.allNumber = sum
									const sum1 = goodsResult.reduce((acc, obj) => acc + (obj.newPrice * obj	.updateNumber), 0);
									that.billData.allPrice = sum1
								}

								
							},
							error: function(xhr) {
								// 只有请求不正常才会执行（状态码不为200）
								console.log(xhr)
							},
						});
					}
				},
				method: {
					
				}
			};
			Vue.createApp(App).mount('#app');
		</script>
	</body>
</html>